Adding combo boxes

If you want to add to your form a combobox referencing another table follow next steps in the OnInitialUpdate() function:

  1. Open the table of the combo box as a cursor selecting as first field the one that will fill the list shown, and as second the hidden Id that will replace the field of the main table
  2. Associate the combobox to the field using AddComboCtrl function
  3. Fill the combobox with FillCombo.

The following example will show the name of the customers in the list and will update the CustId of the Orders table:

OpenCursor( "SELECT * FROM [Orders]"); 
OpenCursor( "SELECT Name,IdCust FROM [Customers] ORDER BY Name");
AddComboCtrl( IDC_CBO_CUST, "IdCust");
FillCombo( IDC_CBO_CUST, 1);

 

NOTE: the Id field must be numeric in both tables, the main form table and the combo box table.